package leetcode;

import java.util.Arrays;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-02-13 10:11
 **/
public class LeetCode1189 {

    public int maxNumberOfBalloons(String text) {
        int[] cnt = new int[5];
        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            if (c == 'b') {
                ++cnt[0];
            } else if (c == 'a') {
                ++cnt[1];
            } else if (c == 'l') {
                ++cnt[2];
            } else if (c == 'o') {
                ++cnt[3];
            } else if (c == 'n') {
                ++cnt[4];
            }
        }

        cnt[2] /= 2;
        cnt[3] /= 2;
        return Arrays.stream(cnt).min().getAsInt();
    }

}
